using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lua4Net;
using MessageSystem.Managed.Rpc;
using MessageSystem.Managed.Infrastructure;
using MessageSystem.Managed;
using MessageSystem.Managed.LuaRpc;

namespace TestLuaClient
{
	class Program
	{
		static RpcCenter rpc;
		static RpcAddress address;
		static RpcPermanentDomain pdomain;
		static void Main(string[] args)
		{
			LuaManager lmanager = new LuaManager();
			lmanager.Initialize(new LuaRpcRegister(), "Lua4NetRoot.lua", "application.lua",
				s => { Console.WriteLine(s); });

			rpc = new RpcCenter(Options.Default, MessageSystemType.Default);
			address = new RpcAddress { Ip = "127.0.0.1", Port = 8001 };
			pdomain = rpc.GetPermanentDomain(address, 3, 10);
			lmanager.Call("gamestart", pdomain, 0);
			lmanager.Call("fire");
			lmanager.Call("fire");
			while (true)
			{
				pdomain.Update();
				lmanager.GC();
				rpc.Poll(10);
			}

			Console.ReadLine();
		}
	}
}
